home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
Borland Visual dBASE Professiona v7.0
/
DATA1.CAB
/
Sample_dBASE
/
structAPI.prg
< prev
next >
Wrap
Text File
|
1997-11-20
|
10KB
|
186 lines
//------------------------------------------------------------------------
//
// StructAPI.prg -- A collection of structure member functions
//
// This script prototypes several functions that are contained
// in the file StrucMem.dll. Once the functions have been
// prototyped, you can use them as you would native dBASE
// functions.
//
// These functions can be used to construct and/or parse
// structure strings. Structure strings are required when
// working with many functions in external DLLs or the
// the Windows API. To exchange a structure with an
// external function, prototype that function with the
// CPTR type. Then create a string variable and exchange
// the string.
//
// Functions prototyped are:
//
// GetStructNumber(<string>, <offset>, <type>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the number
// that you want to get.
// <type> - indicates the datatype of the member. Types
// are defined in the STRUCMEM.H header file.
// return value - the number at offset <offset>
//
// SetStructNumber(<string>, <offset>, <type>, <length>, <value>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the number
// that you want to set.
// <type> - indicates the datatype of the member. Types
// are defined in the STRUCMEM.H header file.
// <length> - is the length of <string>
// <value> - is the numeric value that you want to write
// to the string. *
// return value - is the number of bytes written to the string
//
// GetStructString(<string>, <offset>, <length>, <target>, <target len>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the
// string that you want to get. *
// <length> - is the number of bytes to get
// <target> - this string variable should be blank. It
// will be written to.
// <target len> - is the length of <target>
// return value - is the number of bytes written to the target
//
// SetStructString(<string>, <offset>, <size>, <value>, <value len>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the string
// that you want to set.
// <length> - is the length of the entire <string> structure.
// <value> - this is the string that is written to <string>
// <value len> - is the length of <value>
// return value - is the number of bytes written to the string
//
// GetStructStringLen(<string>, <offset> )
// where <string> - is a string var representing a structure
// modified by an external call.
// <offset> - is the offset in the structure of the string
// that you want to find the lenght of.
// reurn value - is the number of bytes preceding a null byte.
//
// GetStructCharPointer(<string>, <offset>, <length>, <target>,
// <target len>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the string
// that you want to get.
// <length> - is the number of bytes pointed to. This many
// bytes will be copied to <target>. If the
// pointer points to a null terminated string,
// you can use 0 as the length.
// <target> - this string variable should be blank. It will
// be written to.
// <target len> - is the length of <target>
// return value - is the number of bytes written to the target
//
// SetStructCharPointer(<string>, <offset>, <length>, <value>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the string
// that you want to get.
// <length> - is the length of the <string>
// <value> - is a string. A pointer to this string is written
// to the structure at the specified offset. Make
// sure that the <value> variable remains in scope
// during the entire time that you are using the
// structure.
// return value - is the number of bytes written to the string
//
// GetStructWCharPointer(<string>, <offset>, <length>, <target>,
// <target len>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the string
// that you want to get.
// <length> - is the number of bytes pointed to. This many
// bytes will be copied to <target>. If the
// pointer points to a null terminated string,
// you can use 0 as the length.
// <target> - this string variable should be blank. It will
// be written to.
// <target len> - is the length of <target>
// return value - is the number of characters written to the target
//
// The GetStructWCharPointer() function should be used when the
// pointer at <offset> points to a wide char string.
//
// GetStructVoidPointer(<string>, <offset>, <length>, <target>,
// <target len>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the string
// that you want to get.
// <length> - is the number of bytes pointed to. This many
// bytes will be copied to <target>. Unlike the
// GetStructCharPointer method, this one requires
// that the length be correctly set.
// <target> - this string variable should be blank. It will
// be written to.
// <target len> - is the length of <target>
// return value - is the number of bytes written to the target
//
// SetStructVoidPointer(<string>, <offset>, <length>, <value>)
// where <string> - is a string var representing a structure
// <offset> - is the offset in the structure of the string
// that you want to get.
// <length> - is the length of the <string>
// <value> - is a string. A pointer to this string is written
// to the structure at the specified offset. Make
// sure that the <value> variable remains in scope
// during the entire time that you are using the
// structure.
// return value - is the number of bytes written to the string
//
// ConvertToMultiByte(<wstring>,<string>,<length>)
// where <wstring> - is a wide char string
// <string> - is the return buffer for the multibyte string
// <length> - is the length of the return buffer in bytes
//
// ConvertToWideChar(<string>,<wstring>,<length>)
// where <string> - is a multi-byte string
// <wstring> - is the return buffer for the wide char string
// <length> - is the length of the return buffer in bytes
//
// Example:
// See structure.prg for examples.
//
// Visual dBASE Samples Group
// $Revision: 1.6 $
//
// Copyright (c) 1997, Borland International, Inc. All rights reserved.
//
//------------------------------------------------------------------------
local sFolder
SET TALK OFF
sFolder = SUBSTR( PROGRAM(0), 1, ;
LEN( PROGRAM( 0 ) ) - ( LEN( PROGRAM() ) + 4) )
extern CLDOUBLE GetStructNumber(CPTR, CINT, CINT) ;
( sFolder + "strucmem.dll" )
extern CINT SetStructNumber(CPTR, CINT, CINT, CINT, CLDOUBLE) ; ( sFolder + "strucmem.dll" ) extern CINT GetStructString(CPTR, CINT, CINT, CSTRING, CINT) ;
( sFolder + "strucmem.dll" )
extern CINT GetStructStringLen(CPTR, CINT) ;
( sFolder + "strucmem.dll" )
extern CINT SetStructString(CPTR, CINT, CINT, CSTRING, CINT) ;
( sFolder + "strucmem.dll" )
extern CINT GetStructCharPointer(CPTR, CINT, CINT, CSTRING, CINT) ;
( sFolder + "strucmem.dll" )
extern CINT SetStructCharPointer(CPTR, CINT, CINT, CSTRING) ;
( sFolder + "strucmem.dll" ) from "SetStructPointer"
extern CINT GetStructWCharPointer(CPTR, CINT, CINT, CPTR, CINT) ;
( sFolder + "strucmem.dll" ) from "GetStructWCharPointer"
extern CINT GetStructVoidPointer(CPTR, CINT, CINT, CPTR, CINT) ;
( sFolder + "strucmem.dll" ) from "GetStructCharPointer"
extern CINT SetStructVoidPointer(CPTR, CINT, CINT, CPTR) ;
( sFolder + "strucmem.dll" ) from "SetStructPointer"
extern CINT ConvertToMultiByte(CPTR, CPTR, CINT) ;
( sFolder + "strucmem.dll" )
extern CINT ConvertToWideChar(CPTR, CPTR, CINT) ; ( sFolder + "strucmem.dll" )
return true